package shortcode

import "math/rand"

type ShortCode struct {
	lenght int
}

func NewShortCode(lenth int) *ShortCode {
	return &ShortCode{
		lenght: lenth,
	}
}

// 常量
const chars = "OREOERORER454654OFORJF8080flojotrjfofojrf787979"

// 短代码生成器
func (s *ShortCode) GenerateShortCode() string {
	lenghts := len(chars)
	result := make([]byte, s.lenght) //初始化 字节切片类型长度

	for i := 0; i < s.lenght; i++ {
		result[i] = chars[rand.Intn(lenghts)]
	}
	return string(result)
}
